﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_BBSReplay]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_BBSReplay];
GO
CREATE PROCEDURE [dbo].[sproc_BBSReplay] 
    @item_id int,
    @content ntext,
    @replayer nvarchar(300),
    @replay_ip nvarchar(50)
/*

====================================================
功能:    回复帖子
参数:
    @item_id int,        :    帖子ID
    @content ntext        :    回复内容
    @replayer nvarchar(300)    :    回复者
    @replay_ip nvarchar(50)    :    回复着IP
====================================================

*/
AS
--写入回复数据
INSERT INTO uds_bbs_replay
        (item_id,content,replayer,replay_time,replay_ip)
        VALUES(@item_id,@content,@replayer,getdate(),@replay_ip)

--浏览次数减1是是为了抵消回复完再打开时还要加上一次浏览

UPDATE uds_bbs_forumitem
    SET replay_times = replay_times +1 ,last_replayer = @replayer ,last_replay_time = getdate()
    WHERE item_id = @item_id


RETURN @@IDENTITY